package com.jzo2o.foundations.controller.operation;

import com.jzo2o.api.foundations.dto.response.ServeTypeSimpleResDTO;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeTypePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeTypeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.model.dto.response.ServeTypeResDTO;
import com.jzo2o.foundations.service.IServeService;
import com.jzo2o.foundations.service.IServeTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * 服务类型相关接口
 *
 * @author wdm
 * @create 2023/7/26 14:16
 **/
@RestController
@RequestMapping("/operation/serve")
@Api(tags = "区域服务相关接口")
@Slf4j
public class ServeController {
    @Resource
    private IServeService serveService;

    @GetMapping("/page")
    @ApiOperation("根据区域id分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO) {
        return serveService.pageQuery(servePageQueryReqDTO);
    }


    @PostMapping("/batch")
    @ApiOperation("批量添加")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> serveUpsertReqDTOList){
        log.info("{}",serveUpsertReqDTOList);
        serveService.batchAdd(serveUpsertReqDTOList);
    }

    @PutMapping("/{id}")
    @ApiOperation("价格修改")
    public void update(@PathVariable("id") Long id,@RequestParam("price") BigDecimal price){
        serveService.updatePriceById(id,price);
    }

    @PutMapping("/onSale/{id}")
    @ApiOperation("区域服务上架")
    public void onSale(@PathVariable("id") Long id) {
        serveService.onSale(id);
    }

    @PutMapping("/offSale/{id}")
    @ApiOperation("区域服务下架")
    public void offSale(@PathVariable("id") Long id) {
        serveService.offSale(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除区域服务开发")
    public void deleteById(@PathVariable("id")Long id){
        serveService.deleteById(id);
    }

    @PutMapping("/onHot/{id}")
    @ApiOperation("区域服务设置热门开发")
    public void onHot(@PathVariable("id") Long id) {
        serveService.onHot(id);
    }

    @PutMapping("/offHot/{id}")
    @ApiOperation("区域服务取消热门开发")
    public void offHot(@PathVariable("id") Long id) {
        serveService.offHot(id);
    }



}
